Enable lazy construction of label strings#1041
Closed
som-snytt wants to merge 1 commit intotypelevel:mainfrom
Closed
Enable lazy construction of label strings#1041som-snytt wants to merge 1 commit intotypelevel:mainfrom
som-snytt wants to merge 1 commit intotypelevel:mainfrom
Conversation
Contributor
Author
97e168c to
818097a
Compare
818097a to
728710e
Compare
som-snytt
commented
Mar 16, 2024
| val avg = sum / n | ||
| s"average = $avg" |: avg >= 0.49 && avg <= 0.51 | ||
| s"average = $avg".ensuring(false, "eager evaluation") =|= avg >= 0.49 && avg <= 0.51 | ||
| avg >= 0.49 && avg <= 0.51 =|= s"average = $avg" |
Contributor
Author
There was a problem hiding this comment.
just to exercise the idioms in the absence of tests
Contributor
Author
|
On precedence, the trade-off is the |
mrdziuban
reviewed
Mar 22, 2024
| * The label is evaluated lazily. The operator name is chosen for its precedence btween boolean operators and | ||
| * others. | ||
| */ | ||
| def =|=(label: => String): Prop = prop.map(_.label(label)) |
There was a problem hiding this comment.
Another part of my PR (#979) was to avoid evaluating the label if it will never be displayed to the user. What do you think about doing the same here?
def =|=(label: => String): Prop =
prop.map(r =>
r.status match {
case Prop.False | Prop.Exception(_) => r.label(l)
case Prop.Proof | Prop.True | Prop.Undecided => r
})| * | ||
| * The operator name is chosen for its precedence between boolean operators and others. | ||
| */ | ||
| extension (prop: Prop) def =|=(label: => String): Prop = prop.map(_.label(label)) |
There was a problem hiding this comment.
Does Scala 3 not need an extension for Boolean like the Scala 2 version?
|
@satorg @som-snytt do you have any thoughts on moving this or #979 forward? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A different take on #979
Instead of recycling
|:for labeling, use=|=for improved symmetry and operator precedence.A second commit follows up scalafmt config by "fixing" star alignment in doc comments. Edit: That hassle is reserved for another effort.